/** 
  Copyright (c) 2008, 2009 Claudio Imbrenda
  This program is released under the terms of the
  GNU GPL version 3 or later.
*/
package macchina.telescriventi;

import java.io.*;
import macchina.*;
        
/**
 *
 * @author Claudio Imbrenda
 */
public class NastroFileTelescrivente implements RegistroUscita{

  private PrintWriter of;
  
  public NastroFileTelescrivente(File f)throws FileNotFoundException,IOException{
    of=new PrintWriter(new FileWriter(f));
  }

  private static String toTape(byte b){
      String res="";
      res += ((b&16)==0?'_':'o') + ((b&8)==0?'_':'o') + ((b&4)==0?'_':'o')
            +"."+ ((b&2)==0?'_':'o') + ((b&1)==0?'_':'o');
      return res;
  }

  public void write(byte w) {
    of.println(toTape(w));
    of.flush();
  }

}
